import java.util.Scanner;

public class volatile_test {
   static volatile int flag = 0;
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
           while(flag==0){

           }
            System.out.println("循环结束");
        });
        Thread t2 = new Thread(()->{
            Scanner scanner = new Scanner(System.in);
            flag = scanner.nextInt();
        });
        t1.start();
        t2.start();

    }
}
